package xyz.zhno.project.commons.core.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 响应结果集
 * @author zh_o
 * @date 2020-10-31
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Result {

    private String code;

    private String message;

    private Object res;

    /**
     * 成功响应
     * @param message 传入成功秒速
     * @param res 响应数据
     */
    public Result(String message, Object res) {
        this.code = "00000";
        this.message = message;
        this.res = res;
    }

    /**
     * 成功响应
     * @param res 响应数据
     */
    public Result(Object res) {
        this.code = "00000";
        this.message = "success";
        this.res = res;
    }

    /**
     * 成功响应
     * @param message 响应描述
     */
    public Result(String message) {
        this.code = "00000";
        this.message = "success";
    }

    /**
     * 成功响应
     */
    public static Result success(String message, Object res) {
        return new Result(message, res);
    }

    /**
     * 成功响应
     */
    public static Result success(Object res) {
        return new Result(res);
    }

    /**
     * 成功响应
     */
    public static Result success(String message) {
        return new Result(message);
    }
}
